/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



// pour les process que les executes
// pour les protocol les autres performatifs
package model_package;

import java.util.ArrayList;

/**
 *
 * @author haythem
 */
public class AlphaAlgorithmForProcess {

    // the Log to analyse
    private Log log ;
    
    // list of tasks in the Log
    private ArrayList<String> listTasks ;

    // list of initial tasks
    private ArrayList<String> listInitialTasks ;

    // list of final tasks
    private ArrayList<String> listFinalTasks ;

    // list of tasks related by a sucession relation
    private ArrayList<SuccessionRelation> listSuccessionRelations;

    // list of tasks related by a causality relation
    private ArrayList<CausalityRelation> listCausalityRelations;

    // list of tasks related by a choice relation
    private ArrayList<ChoiceRelation> listChoiceRelations;

    // list of relations described in step 4 of the algorithm
    private ArrayList<CausalityRelationSet> listCausalityRelationSets;

    // the minimal one (step 5)
    private ArrayList<CausalityRelationSet> listMinimalCausalityRelationSets;


    /**
     *
     * @param log
     */
    public AlphaAlgorithmForProcess(Log log) {
        this.log = log;
        listTasks = new  ArrayList<String>();
        listInitialTasks = new ArrayList<String>();
        listFinalTasks = new ArrayList<String>();
        listSuccessionRelations = new ArrayList<SuccessionRelation>();
        listCausalityRelations = new ArrayList<CausalityRelation>();
        listChoiceRelations = new ArrayList<ChoiceRelation>();
        listCausalityRelationSets = new ArrayList<CausalityRelationSet>();
        listMinimalCausalityRelationSets = new ArrayList<CausalityRelationSet>();
    }




    ////////////////////////////////////////////////////////////////////
    ///////////////////////// getters and setters /////////////////////
    ///////////////////////////////////////////////////////////////////


     public ArrayList<CausalityRelationSet> getListCausalityRelationSets() {
        return listCausalityRelationSets;
    }

    public void setListCausalityRelationSets(ArrayList<CausalityRelationSet> listCausalityRelationSets) {
        this.listCausalityRelationSets = listCausalityRelationSets;
    }

    public ArrayList<CausalityRelation> getListCausalityRelations() {
        return listCausalityRelations;
    }

    public void setListCausalityRelations(ArrayList<CausalityRelation> listCausalityRelations) {
        this.listCausalityRelations = listCausalityRelations;
    }

    public ArrayList<ChoiceRelation> getListChoiceRelations() {
        return listChoiceRelations;
    }

    public void setListChoiceRelations(ArrayList<ChoiceRelation> listChoiceRelations) {
        this.listChoiceRelations = listChoiceRelations;
    }

    public ArrayList<String> getListFinalTasks() {
        return listFinalTasks;
    }

    public void setListFinalTasks(ArrayList<String> listFinalTasks) {
        this.listFinalTasks = listFinalTasks;
    }

    public ArrayList<String> getListInitialTasks() {
        return listInitialTasks;
    }

    public void setListInitialTasks(ArrayList<String> listInitialTasks) {
        this.listInitialTasks = listInitialTasks;
    }

    public ArrayList<CausalityRelationSet> getListMinimalCausalityRelationSets() {
        return listMinimalCausalityRelationSets;
    }

    public void setListMinimalCausalityRelationSets(ArrayList<CausalityRelationSet> listMinimalCausalityRelationSets) {
        this.listMinimalCausalityRelationSets = listMinimalCausalityRelationSets;
    }

    public ArrayList<SuccessionRelation> getListSuccessionRelations() {
        return listSuccessionRelations;
    }

    public void setListSuccessionRelations(ArrayList<SuccessionRelation> listSuccessionRelations) {
        this.listSuccessionRelations = listSuccessionRelations;
    }

    public ArrayList<String> getListTasks() {
        return listTasks;
    }

    public void setListTasks(ArrayList<String> listTasks) {
        this.listTasks = listTasks;
    }

    public Log getLog() {
        return log;
    }

    public void setLog(Log log) {
        this.log = log;
    }



    ////////////////////////////////////////////////////////////////////
    /////////////////////////    other methods    /////////////////////
    ///////////////////////////////////////////////////////////////////

    /**
     * this method sets the list of all tasks that exist in the log
     */
    public void getTasks(){
        for (int i=0;i<this.log.getListCases().size();i++){
            for (int j=0;j<this.log.getListCases().get(i).getEventsList().size();j++){
                this.listTasks.add(this.log.getListCases().get(i).getEventsList().get(j).getTask());
            }
        }
    }

    /**
     * this methos allows to get the list of initial tasks
     * in the Log
     */
    public void getInitialTasks(){
        for (int i=0;i<this.log.getListCases().size();i++){
            this.listInitialTasks.add(this.log.getListCases().get(i).getEventsList().get(0).getTask());
        }
    }


    public void getFinalTasks(){
        for (int i=0;i<this.log.getListCases().size();i++){
            this.listFinalTasks.add(this.log.getListCases().get(i).getEventsList().get(this.log.getListCases().get(i).getEventsList().size()-1).getTask());
        }
    }



}
